﻿/// ---------------------------------------------
///
/// ---------------------------------------------

///---------------------------

//双击事件
function CustomDbClick() {
    //parent.closeWin(); //去掉双击功能
    fnViewDetail();
}


//添加信息
var fnCustomAdd = function () {
    const_EditEntity = "wkWorkBill";
    var pagetitle = "新增出差单据";
    parent._employeeTitle = pagetitle;
    parent.addTabs(pagetitle, encodeURI("../Extend/Edit.aspx?r=" + Math.random() + "&entity=" + const_EditEntity + "&fun=add&billtype=TRIP"));
    parent.NeedRefreshPage = this;
}

//修改信息
var fnCustomEdit = function () {
    var recordID = myDataTable.getSelectedRows()[0];
    record = myDataTable.getRecord(recordID);
    if (record == null) {
        alert("请选择一条记录");
        return;
    }
    //debugger;
    const_EditEntity = "wkWorkBill";
    var pagetitle = "修改出差单据";
    parent._employeeTitle = pagetitle;
    parent.addTabs(pagetitle, encodeURI("../Extend/Edit.aspx?r=" + Math.random() + "&entity=" + const_EditEntity + "&fun=edit&billtype=TRIP" + "&id=" + record.getData(const_entityID)));
    parent.NeedRefreshPage = this;

}

//查看
var fnViewDetail = function () {
    var recordID = myDataTable.getSelectedRows()[0];
    record = myDataTable.getRecord(recordID);
    if (record == null) {
        alert("请选择一条记录");
        return;
    }
    const_EditEntity = "wkWorkBill";
    //debugger;
    var pagetitle = "查看出差单据" ;
    parent._employeeTitle = pagetitle;
    parent.addTabs(pagetitle, encodeURI("../Extend/Edit.aspx?r=" + Math.random() + "&entity=" + const_EditEntity + "&fun=view&billtype=TRIP" + "&id=" + record.getData(const_entityID)));
    parent.NeedRefreshPage = this;
}

//查看明细
var fnLinkItem = function (elCell, oRecord, oColumn, sData) {
    //debugger;
    elCell.innerHTML = "<a href=\"#\" onclick=\"javascript:fnOpenItem('" + oRecord.getData("WorkFlowInsId") + "','" + sData + "');\">" + sData + "</a>";
};

//打开链接
var fnOpenItem = function (workFlowInsId, workFlowNo) {
    GetWorkFlowInfo(workFlowNo);
}

//获取流程信息
function GetWorkFlowInfo(workFlowNo) {
    YAHOO.util.Connect.asyncRequest('POST', "../EHR/workTimeAjax.aspx?flag=GetWorkFlowInfo&workFlowNo=" + workFlowNo, {
        success: function (res) {
            try {
                var str = res.responseText.split("|");
                //debugger;
                if (str[0] == "1") {
                    var OperatorInstanceId = str[1];
                    var WorkTaskInstanceId = str[2];
                    var FlowCaptions = str[3];
                    var pagetitle = FlowCaptions;
                    parent._employeeTitle = pagetitle;
                    var url = '"' + "../../Crm/BasePages/WorkTaskCtrlPage.aspx?OperatorInstanceId=" + OperatorInstanceId + "&WorkTaskInstanceId=" + WorkTaskInstanceId + '"';
                    parent.addTabs(pagetitle, encodeURI(url));
                    parent.NeedRefreshPage = this;
                }
                else {
                    alert("获取流程信息失败！");
                }
            }
            catch (e) { }
            finally { }
        },
        failure: function (error) {
            alert("获取流程信息数据错误：" + error.statusText);
        }
    }, null);
}

//初始化
if (typeof ($) != "undefined") {
    $(document).ready(function () {

    });
}


